import axios from 'axios'

const service = axios.create({
  baseURL: 'https://api-hmzs.itheima.net/api',
  timeout: 5000,
})

service.interceptors.request.use(
  config => {
    // 携带 token
    return config
  },
  error => {
    return Promise.reject(error)
  }
)

service.interceptors.response.use(
  response => {
    // 统一的异常处理
    return response.data
  },
  error => {
    return Promise.reject(error)
  }
)

export default service
